package com.ashen.study.entity;

import com.ashen.study.model.request.UserRequest;

/**
 * @author huangxiaolin
 * @version 1.0.0
 * @ClassName UserInfo.java
 * @Description
 * @createTime 2019年05月06日 15:16:00
 */
public class UserInfo {

    private Long id;

    private String name;

    private Integer sex;

    private Integer age;

    private  String address;



    private  static UserInfo instance = new UserInfo();
    private UserInfo() {
    }
    public static UserInfo getInstance(){
        return instance;
    }



    /**
     * 新增
     *
     * @param request
     * @return
     * @date 2019/11/20 11:22
     * @author hxl
     **/
    public static UserInfo addOf(UserRequest request) {
        instance.setName(request.getName());
        instance.setSex(request.getSex());
        instance.setAge(request.getAge());
        instance.setAddress(request.getAddress());
        return instance;
    }


    /**
     * 更新
     *
     * @param request
     * @return
     * @date 2019/11/20 11:22
     * @author hxl
     **/
    public static UserInfo updateOf(UserRequest request) {
        instance.setId(request.getId());
        instance.setName(request.getName());
        instance.setSex(request.getSex());
        instance.setAge(request.getAge());
        instance.setAddress(request.getAddress());
        return instance;
    }




    public UserInfo(UserRequest userRequest) {
        this.id = userRequest.getId();
        this.name =userRequest.getName();
        this.sex = userRequest.getSex();
        this.age =userRequest.getAge();
        this.address = userRequest.getAddress();
    }

    public UserInfo(Long id, String name) {
        this.id = id;
        this.name = name;
    }



    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getSex() {
        return sex;
    }

    public void setSex(Integer sex) {
        this.sex = sex;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }
}
